﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //khoi tao tin tuc
        InitializeNews();

        //khoi tao dich vu ua thich
        InitializeRatingService();
                
        //khoi tao san pham ua thich
        InitializeRatingProduct();
    }

    void InitializeRatingProduct()
    {        
        BonSaiTableAdapters.ProductsTableAdapter pdADT = new BonSaiTableAdapters.ProductsTableAdapter();
        BonSai.ProductsDataTable pd = pdADT.GetRandomProduct();        
        imageRatingProduct1.Src = "img_product/"+pd.Rows[0][11].ToString();
        imageRatingProduct2.Src = "img_product/" + pd.Rows[1][11].ToString();
        imageRatingProduct3.Src = "img_product/" + pd.Rows[2][11].ToString();
        imageRatingProduct4.Src = "img_product/" + pd.Rows[3][11].ToString();

        nameRatingProduct1.InnerText = pd.Rows[0][1].ToString();
        nameRatingProduct2.InnerText = pd.Rows[1][1].ToString();
        nameRatingProduct3.InnerText = pd.Rows[2][1].ToString();
        nameRatingProduct4.InnerText = pd.Rows[3][1].ToString();
    }

    void InitializeNews()
    {
        BonSaiTableAdapters.NewsTableAdapter nADT = new BonSaiTableAdapters.NewsTableAdapter();
        BonSai.NewsDataTable n = nADT.GetHotNews();
        imageNews1.Src = "img_news/" + n.Rows[0][4].ToString();
        imageNews2.Src = "img_news/" + n.Rows[1][4].ToString();
        imageNews3.Src = "img_news/" + n.Rows[2][4].ToString();
        imageNews4.Src = "img_news/" + n.Rows[3][4].ToString();

        titleNews1.InnerText = n.Rows[0][1].ToString();
        titleNews2.InnerText = n.Rows[1][1].ToString();
        titleNews3.InnerText = n.Rows[2][1].ToString();
        titleNews4.InnerText = n.Rows[3][1].ToString();

        contentNews1.InnerText = n.Rows[0][2].ToString();
        contentNews2.InnerText = n.Rows[1][2].ToString();
        contentNews3.InnerText = n.Rows[2][2].ToString();
        contentNews4.InnerText = n.Rows[3][2].ToString();
    }

    void InitializeRatingService()
    {
        BonSaiTableAdapters.ServiceTableAdapter svADT = new BonSaiTableAdapters.ServiceTableAdapter();
        BonSai.ServiceDataTable sv = svADT.GetRandomService();

        imageService.Src = "img_service/" + sv.Rows[0][3].ToString();
        nameService.InnerText = sv.Rows[0][1].ToString();
        contentService.InnerHtml = sv.Rows[0][2].ToString();
    }
}
